<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.conn.RecordSetDataSource" %>
<%@ page import="weaver.general.BaseBean" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="weaver.interfaces.xz.Util.WorkflowCreateHandler" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Map" %>
<%--
 Created on 2019-12-18
 Copyright (c) 2001-2019 泛微软件
 泛微协同商务系统，版权所有。
 功能 测试
--%>
<%@ page language="java" contentType="text/html; charset=utf-8" %>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page"/>
<jsp:useBean id="bb" class="weaver.general.BaseBean"/>
<%
    String handleDate = request.getParameter( "handleDate" );//用request得到
    bb.writeLog( "handleDate=" + handleDate );
    String message = execute( handleDate );
    out.print( message.toString() );
%>
<%!
    public String execute(String handleDate) {
        BaseBean baseBean = new BaseBean();
        baseBean.writeLog( "---ManualHandle---" );
        RecordSet rs = new RecordSet();
        RecordSet rs1 = new RecordSet();
        WorkflowCreateHandler handler = new WorkflowCreateHandler();
        RecordSetDataSource rsd1 = new RecordSetDataSource( "dcxt" );
        RecordSetDataSource rsd2 = new RecordSetDataSource( "dcxt" );
        RecordSetDataSource rsd3 = new RecordSetDataSource( "dcxt" );
        RecordSetDataSource rsd4 = new RecordSetDataSource( "dcxt" );
        String message = "";
        //为民办实事
        String sql1 = "select * from V_ForPeople where convert(varchar(100),AddTime,23)= '" + handleDate + "'";
        baseBean.writeLog( sql1 );
        rsd1.execute( sql1 );
        int count1 = 0;
        while (rsd1.next()) {
            String Id = Util.null2String( rsd1.getString( "Id" ) );//ID
            String SendUser = Util.null2String( rsd1.getString( "SendUser" ) );//发送人
            rs.executeQuery( "select id from hrmresource where lastname='" + SendUser + "'" );
            rs.next();
            String userid = Util.null2String( rs.getString( "id" ) );
            String ProjectName = Util.null2String( rsd1.getString( "ProjectName" ) );//项目名称
            String DepName = Util.null2String( rsd1.getString( "DepName" ) );//部门名称
            rs1.executeQuery( "select t.id,t.departmentid from hrmResource t left join hrmdepartment d on t.departmentid=d.id  where departmentname='" + DepName + "'" );
            rs1.next();
            String workid = Util.null2String( rs1.getString( "id" ) );//人员ID
            String departmentid = Util.null2String( rs1.getString( "departmentid" ) );//部门ID
            String AddTime = Util.null2String( rsd1.getString( "AddTime" ) ).substring( 0, 10 );//时间
            String creatorId = workid;
            String workflowId = "6903";
            String requestName = ProjectName;
            String IsNextFlow = "0";
            Map<String, String> requestMainMap = new HashMap<String, String>();
            requestMainMap.put( "fsr1", userid );//发送人
            requestMainMap.put( "jsdw1", departmentid );//接收单位
            requestMainMap.put( "rq", AddTime );//日期
            requestMainMap.put( "zw", ProjectName );
            requestMainMap.put( "wybs", Id );//主键
            requestMainMap.put( "sxlx", "0" );//事项类型
            handler.WorkflowCreateByRequestMap( creatorId, workflowId, requestName, IsNextFlow, requestMainMap );
            count1++;
        }
        String V_ForPeople = "为民办实事创建流程记录数[" + count1 + "]";
        //政府工作报告
        String sql2 = "select * from V_GovernmentWork where convert(varchar(100),AddTime,23)= '" + handleDate + "'";
        rsd2.execute( sql2 );
        baseBean.writeLog( sql2 );
        int count2 = 0;
        while (rsd2.next()) {
            String Id = Util.null2String( rsd2.getString( "Id" ) );//主键
            String SendUser = Util.null2String( rsd2.getString( "SendUser" ) );//发送人
            rs.executeQuery( "select id from hrmresource where lastname='" + SendUser + "'" );
            rs.next();
            String userid = Util.null2String( rs.getString( "id" ) );
            String AttachmentPath = Util.null2String( rsd2.getString( "AttachmentPath" ) );//附件路径
            String DepName = Util.null2String( rsd2.getString( "DepName" ) );//单位
            rs1.executeQuery( "select t.id,t.departmentid from hrmResource t left join hrmdepartment d on t.departmentid=d.id  where departmentname='" + DepName + "'" );
            rs1.next();
            String workid = Util.null2String( rs1.getString( "id" ) );//人员ID
            String departmentid = Util.null2String( rs1.getString( "departmentid" ) );//部门ID
            String AddTime = Util.null2String( rsd2.getString( "AddTime" ) ).substring( 0, 10 );//时间
            String Title = Util.null2String( rsd2.getString( "Title" ) );//标题
            String creatorId = workid;
            String workflowId = "6903";
            String requestName = Title;
            String IsNextFlow = "0";
            Map<String, String> requestMainMap = new HashMap<String, String>();
            requestMainMap.put( "fsr1", userid );//发送人
            requestMainMap.put( "jsdw1", departmentid );//接收单位
            requestMainMap.put( "rq", AddTime );//日期
            requestMainMap.put( "wybs", Id );//主键
            requestMainMap.put( "sxlx", "1" );//事项类型
            requestMainMap.put( "zw", Title );//事项类型
            requestMainMap.put( "fj", AttachmentPath );//事项类型
            handler.WorkflowCreateByRequestMap( creatorId, workflowId, requestName, IsNextFlow, requestMainMap );
            count2++;
        }
        String V_GovernmentWork = "政府工作报告创建流程记录数[" + count2 + "]";
        //重点工程/重大产业项目
        String sql3 = "select * from V_Major where convert(varchar(100),AddTime,23)= '" + handleDate + "'";
        baseBean.writeLog( sql3 );
        rsd3.execute( sql3 );
        int count3 = 0;
        while (rsd3.next()) {
            String Id = Util.null2String( rsd3.getString( "Id" ) );//主键
            String SendUser = Util.null2String( rsd3.getString( "SendUser" ) );
            rs.executeQuery( "select id from hrmresource where lastname='" + SendUser + "'" );
            rs.next();
            String userid = Util.null2String( rs.getString( "id" ) );
            String ProjectName = Util.null2String( rsd3.getString( "ProjectName" ) );
            String DepName = Util.null2String( rsd3.getString( "DepName" ) );
            rs1.executeQuery( "select t.id,t.departmentid from hrmResource t left join hrmdepartment d on t.departmentid=d.id  where departmentname='" + DepName + "'" );
            rs1.next();
            String workid = Util.null2String( rs1.getString( "id" ) );//人员ID
            String departmentid = Util.null2String( rs1.getString( "departmentid" ) );//部门ID
            String AddTime = Util.null2String( rsd3.getString( "AddTime" ) ).substring( 0, 10 );//时间
            String creatorId = workid;
            String workflowId = "6903";
            String requestName = ProjectName;
            String IsNextFlow = "0";
            Map<String, String> requestMainMap = new HashMap<String, String>();
            requestMainMap.put( "fsr1", userid );//发送人
            requestMainMap.put( "jsdw1", departmentid );//接收单位
            requestMainMap.put( "rq", AddTime );//日期
            requestMainMap.put( "zw", ProjectName );
            requestMainMap.put( "wybs", Id );//主键
            requestMainMap.put( "sxlx", "2" );//事项类型
            handler.WorkflowCreateByRequestMap( creatorId, workflowId, requestName, IsNextFlow, requestMainMap );
            count3++;
        }
        String V_Major = "政府工作报告创建流程记录数[" + count3 + "]";
        //专项通报
        String sql4 = "select * from V_ToDo where convert(varchar(100),AddTime,23)= '" + handleDate + "'";
        rsd4.execute( sql4 );
        baseBean.writeLog( sql4 );
        int count4 = 0;
        while (rsd4.next()) {
            String Id = Util.null2String( rsd4.getString( "Id" ) );//主键
            String SendUser = Util.null2String( rsd4.getString( "SendUser" ) );
            rs.executeQuery( "select id from hrmresource where lastname='" + SendUser + "'" );
            rs.next();
            String userid = Util.null2String( rs.getString( "id" ) );
            String AttachmentPath = Util.null2String( rsd4.getString( "AttachmentPath" ) );
            String DepName = Util.null2String( rsd4.getString( "DepName" ) );
            rs1.executeQuery( "select t.id,t.departmentid from hrmResource t left join hrmdepartment d on t.departmentid=d.id  where departmentname='" + DepName + "'" );
            rs1.next();
            String workid = Util.null2String( rs1.getString( "id" ) );//人员ID
            String departmentid = Util.null2String( rs1.getString( "departmentid" ) );//部门ID
            String AddTime = Util.null2String( rsd4.getString( "AddTime" ) ).substring( 0, 10 );//时间
            String Title = Util.null2String( rsd4.getString( "Title" ) );//标题
            String creatorId = workid;
            String workflowId = "6903";
            String requestName = Title + AddTime;
            String IsNextFlow = "0";
            Map<String, String> requestMainMap = new HashMap<String, String>();
            requestMainMap.put( "fsr1", userid );//发送人
            requestMainMap.put( "jsdw1", departmentid );//接收单位
            requestMainMap.put( "rq", AddTime );//日期
            requestMainMap.put( "wybs", Id );//主键
            requestMainMap.put( "sxlx", "3" );//事项类型
            requestMainMap.put( "zw", Title );//事项类型
            requestMainMap.put( "fj", AttachmentPath );//事项类型
            handler.WorkflowCreateByRequestMap( creatorId, workflowId, requestName, IsNextFlow, requestMainMap );
            count4++;
        }
        String V_ToDo = "政府工作报告创建流程记录数[" + count4 + "]";
        return message = V_ForPeople + " ;" + V_GovernmentWork + " ;" + V_Major + " ;" + V_ToDo;
    }

%>
<script>

</script>